package com.haiqi.modules.ship.service;

import com.github.pagehelper.PageInfo;
import com.haiqi.common.bean.PageBean;
import com.haiqi.common.persistence.dao.ShipFollowMapper;
import com.haiqi.common.persistence.entity.ShipFollow;
import com.haiqi.common.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by liuxiayan on 2017/5/12.
 */
@Service
public class ShipFollowService {
    @Autowired
    private ShipFollowMapper shipFollowMapper;
    public boolean addship(ShipFollow shipFollow) {
        return shipFollowMapper.addship(shipFollow);
    }

    public boolean updateFollow(ShipFollow shipFollow) {
        return shipFollowMapper.updateByPrimaryKeySelective(shipFollow);
    }

    public ShipFollow selectFollow(Integer sfid) {
        ShipFollow shipFollow = shipFollowMapper.selectFollow(sfid);
        return shipFollow;
    }
    public ShipFollow findBymmsiAndGuanid(String mmsi,Integer guanid){
        return shipFollowMapper.findBymmsiAndGuanid(mmsi,guanid);
    }
    public List<ShipFollow> findByGuanId(Integer id){
        return shipFollowMapper.findByGuanId(id);
    }

    public boolean deleteGZ(Integer id){
        return shipFollowMapper.deleteGZ(id);
    }
    public boolean deleteById(Integer sfid){return shipFollowMapper.deleteById(sfid);}
    public ShipFollow findByMmsi(String mmsi){
        return shipFollowMapper.findByMmsi(mmsi);
    }

    public PageInfo<ShipFollow> select(ShipFollow shipFollow, PageBean pageBean){

        PageUtils.generatePage(pageBean);
        List<ShipFollow> shipFollowList=shipFollowMapper.select(shipFollow);
        PageInfo<ShipFollow> shipFollowPage=new PageInfo<>(shipFollowList);

        return shipFollowPage;
    }
}
